a tool for shared writing and social publishing
1import { makeRouter } from "../lib";
2import { push } from "./push";
3import { createClient } from "@supabase/supabase-js";
4import { Database } from "supabase/database.types";
5import { pull } from "./pull";
6import { getFactsFromHomeLeaflets } from "./getFactsFromHomeLeaflets";
7import { Vercel } from "@vercel/sdk";
8import {
9 get_domain_status,
10 get_leaflet_subdomain_status,
11} from "./domain_routes";
12import { get_leaflet_data } from "./get_leaflet_data";
13import { get_publication_data } from "./get_publication_data";
14import { search_publication_names } from "./search_publication_names";
15import { search_publication_documents } from "./search_publication_documents";
16import { get_profile_data } from "./get_profile_data";
17import { get_user_recommendations } from "./get_user_recommendations";
18
19let supabase = createClient<Database>(
20 process.env.NEXT_PUBLIC_SUPABASE_API_URL as string,
21 process.env.SUPABASE_SERVICE_ROLE_KEY as string,
22);
23
24const VERCEL_TOKEN = process.env.VERCEL_TOKEN;
25const vercel = new Vercel({
26 bearerToken: VERCEL_TOKEN,
27});
28const Env = {
29 supabase,
30 vercel,
31};
32export type Env = typeof Env;
33export type Routes = typeof Routes;
34let Routes = [
35 push,
36 pull,
37 getFactsFromHomeLeaflets,
38 get_domain_status,
39 get_leaflet_subdomain_status,
40 get_leaflet_data,
41 get_publication_data,
42 search_publication_names,
43 search_publication_documents,
44 get_profile_data,
45 get_user_recommendations,
46];
47export async function POST(
48 req: Request,
49 { params }: { params: Promise<{ command: string }> },
50) {
51 let p = await params;
52 let router = makeRouter(Routes);
53 return router(p.command, req, Env);
54}